home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / signal / remezfilt.dem < prev    next >
Text File  |  1999-09-16  |  944b  |  36 lines

  1. function []=remezfilt()
  2. ////////////////////////
  3. //MINIMAX FIR FILTERS///
  4. ////////////////////////
  5. //   clear 
  6. //Low pass filter (length 33, cut-off in [.23,.27], weight 1/.1)
  7.    hn=eqfir(33,[0 .23;.27 .5],[1 0],[1 .1]);
  8.    [hm,fr]=frmag(hn,256);
  9.    plot2d(fr',hm'),
  10.    title_c=['Minimax FIR filter';
  11.        'low pass  cut-off in [.23,.27]';
  12.           'length 33'];
  13.    xtitle(title_c);
  14.    halt(),xbasc();
  15.  
  16. //Triangular filter created using remezb
  17.    nc=21;
  18.    ngrid=nc*16;
  19.    fg=.5*(0:(ngrid-1))/(ngrid-1);
  20.    ds(1:ngrid/2)=(0:-1+ngrid/2)*2/(ngrid-2);
  21.    ds(ngrid/2+1:ngrid)=ds(ngrid/2:-1:1);
  22.    wt=ones(fg);
  23.    [an]=remezb(nc,fg,ds,wt);
  24.    hn(1:nc-1)=an(nc:-1:2)/2;
  25.    hn(nc)=an(1);
  26.    hn(nc+1:2*nc-1)=an(2:nc)/2;
  27.    [hm,fr]=frmag(hn,maxi(size(ds)));
  28.    plot2d(fr',hm'),
  29.    xtitle('Remez Triangular filter','frequency','magnitude');
  30.    halt();xbasc(); 
  31.    plot2d(fr',(hm-ds)'),
  32.    xtitle(' ','frequency','magnitude error');
  33.    halt(),xbasc();
  34.  
  35.  
  36.